<?php
global $General,$wpdb;
if($_SESSION['couponcode'])
{
	if(!$General->is_valid_couponcode($_SESSION['couponcode']))
	{
		wp_redirect(site_url('/?ptype=cart&msg=invalidcoupon'));
		exit;
	}
}
//$_SESSION['redirect_page'] = 'ptype=checkout';
$userInfo = $General->getLoginUserInfo();
global $current_user;
$user_address_info = get_user_meta($current_user->data->ID,'user_address_info');
$user_add1 = $user_address_info[0]['user_add1'];
$user_add2 = $user_address_info[0]['user_add2'];
$user_city = $user_address_info[0]['user_city'];
$user_state = $user_address_info[0]['user_state'];
$user_country = $user_address_info[0]['user_country'];
$phone = $user_address_info[0]['phone'];
$user_postalcode = $user_address_info[0]['user_postalcode'];
$display_name = $userInfo['display_name'];
$display_name_arr = explode(' ',$display_name);
$user_fname = $display_name_arr[0];
$display_name_arr[1]=="" ? $user_lname = $display_name_arr[2]:$user_lname = $display_name_arr[1];
$buser_add1 = $user_address_info[0]['buser_add1'];
$buser_add2 = $user_address_info[0]['buser_add2'];
$buser_city = $user_address_info[0]['buser_city'];
$buser_state = $user_address_info[0]['buser_state'];
$buser_country = $user_address_info[0]['buser_country'];
$buser_postalcode = $user_address_info[0]['buser_postalcode'];
$bdisplay_name = $user_address_info[0]['buser_name'];
$bphone = $user_address_info[0]['bphone'];
$display_name_arr = explode(' ',$bdisplay_name);
$buser_fname = $display_name_arr[0];
$buser_lname = $display_name_arr[2];

if($_SESSION['redirect_page'] == '')
{
	$_SESSION['redirect_page'] = $_SERVER['HTTP_REFERER'];
}
if(strstr($_SESSION['redirect_page'],'ptype=checkout'))
{
	global $General;
	$login_redirect_link = $General->get_ssl_normal_url(site_url('/?ptype=checkout'));
}
?>

</div>
<div>
<div>
  <?php
  if($login_redirect_link)
  {
  ?>
  <?php }?>

<form name="confirmaddress" id="registerform" action="<?php echo site_url('/?ptype=checkout'); ?>" method="post">
  <?php 
  if($_REQUEST['msg']=='success')
  {
  	$message = "Information Updated successfully.";
  }
  if($message) { ?>
  <div class="sucess_msg"> <?php _e(MYACC_INFO_UPDATE_MSG);?> </div>
  </td>
  <?php } ?>
  <div>
    <div  class="form-holder small">
      <h5><?php _e(BILLING_ADDRESS_TEXT);?> </h5>
<?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/edit_profile_before_edit_form_fields.php'))
{
	include_once(CHILDTEMPLATEPATH . '/edit_profile_before_edit_form_fields.php');
}
?>
<ul>
	<li><label><?php _e(FIRST_NAME_TEXT) ?></label><p><?php echo $user_fname; ?></p></li>
    <li><label><?php _e(LAST_NAME_TEXT) ?></label><p><?php echo $user_lname; ?></p></li>
    <li><label><?php _e(ADDRESS1_TEXT) ?></label><p><?php echo $user_add1; ?></p></li>
    <li><label><?php _e(ADDRESS2_TEXT) ?></label><p><?php echo $user_add2; ?></p></li>
    <li><label><?php _e(COUNTRY_TEXT) ?></label><p><?php echo $user_country;?></p></li>
    <li><label><?php _e(STATE_TEXT) ?></label><p><?php echo $user_state;?></p></li>
    <li><label><?php _e(CITY_TEXT) ?></label><p><?php echo $user_city; ?></p></li>
    <li><label><?php _e(POSTAL_CODE_TEXT) ?></label><p><?php echo $user_postalcode; ?></p></li>
    <li><label><?php _e('Phone') ?></label><p><?php echo $phone; ?></p></li>
    <li><a href="<?php echo site_url('/?ptype=myaccount&type=editprofile'); ?>">Click here to edit</a></li>
</ul>
        <?php
	if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/edit_profile_after_billing_fields.php'))
	{
		include_once(CHILDTEMPLATEPATH . '/edit_profile_after_billing_fields.php');
	}
	?>
    </div>
    <!-- my order col_1 End -->
     <?php
    if(!$General->is_storetype_digital())
	{
	?>
    <div class="form-holder small even">
      <h5><?php _e(SHIPPING_ADDRESS_TEXT);?></h5>
      <ul>
      	<li><label><?php _e(FIRST_NAME_TEXT) ?>:</label><p><?php echo $buser_fname; ?></p></li>
        <li><label><?php _e(LAST_NAME_TEXT) ?>:</label><p><?php echo $buser_lname; ?></p></li>
        <li><label><?php _e(ADDRESS1_TEXT) ?>:</label><p><?php echo $buser_add1; ?></p></li>
        <li><label><?php _e(ADDRESS2_TEXT) ?>:</label><p><?php echo $buser_add2; ?></p></li>
        <li><label><?php _e(COUNTRY_TEXT) ?>:</label><p><?php echo $buser_country;?></p></li>
        <li><label><?php _e(STATE_TEXT) ?>:</label><p><p><?php echo $buser_state;?></p></p></li>
        <li><label><?php _e(CITY_TEXT) ?>:</label><p><?php echo $buser_city; ?></p></li>
        <li><label><?php _e(POSTAL_CODE_TEXT) ?>:</label><p><?php echo $buser_postalcode; ?></p></li>
        <li><label><?php _e('Phone') ?> :</label><p><?php echo $bphone; ?></p></li>
	    <li><a href="<?php echo site_url('/?ptype=myaccount&type=editprofile'); ?>">Click here to edit</a></li>
      </ul>
       <?php
	if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/edit_profile_after_shipping_fields.php'))
	{
		include_once(CHILDTEMPLATEPATH . '/edit_profile_after_shipping_fields.php');
	}
	?>
    </div>
    <?php }?>
    <!-- my order col_1 End -->
  </div>
  <?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/edit_profile_after_edit_form_fields.php'))
{
	include_once(CHILDTEMPLATEPATH . '/edit_profile_after_edit_form_fields.php');
}
?>
<div class="cart-bottom">
  <a class="normal_input_btn fl back" href="<?php echo site_url('/?ptype=cart'); ?>">Back</a>
  <input type="button" name="<?php _e('Checkout');?>" value="<?php _e(CONFIRM_BUTTON);?>&raquo;" onclick="document.confirmaddress.submit();" class="highlight_input_btn fr" />
  </div>
</form>

</div>
</div>
